package com.example.fp.cgc.mapper

import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.example.fp.cgc.entity.UserSetting
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update

/**
 * @since 2020-02-28
 * @author 蔡
 */
interface UserSettingMapper : BaseMapper<UserSetting> {
    /**
     * 获取用户设置状态
     */
    @Select("SELECT * FROM user_setting WHERE uid = #{uid}")
    fun getState(uid: Int): List<UserSetting>

    /**
     * 设置是否显示离线列表
     */
    @Update("UPDATE user_setting SET offline = #{state} WHERE uid = #{uid}")
    fun setOffline(uid: Int, state: Boolean)

    /**
     * 设置是否显示历史聊天
     */
    @Update("UPDATE user_setting SET history = #{state} WHERE uid = #{uid}")
    fun setHistory(uid: Int, state: Boolean)

    /**
     * 设置是否显示未读消息数量
     */
    @Update("UPDATE user_setting SET unread = #{state} WHERE uid = #{uid}")
    fun setUnread(uid: Int, state: Boolean)
}